#ifndef ZTCPDATA_H
#define ZTCPDATA_H

#include <QDateTime>
#include <QObject>
#include <QTcpSocket>
#include <QDataStream>
#include <QDebug>


class ZTcpData : public QObject
{
    Q_OBJECT
public:
    explicit ZTcpData(QObject *parent = nullptr);
    ~ZTcpData();
    ZTcpData(const ZTcpData &data);
    void operator = (const ZTcpData &data);

    const QString &Ip() const;
    void setIp(const QString &newIp);

    int Port() const;
    void setPort(int newPort);

    const QString &Name() const;
    void setName(const QString &newName);

    const QDateTime &Time() const;
    void setTime(const QDateTime &newTime);

    const QString &Content() const;
    void setContent(const QString &newContent);

signals:
private:
    QString m_Ip;
    int m_Port;
    QString m_Name;
    QDateTime m_Time;
    QString m_Content;
    friend QDataStream &operator<<(QDataStream &ds,const ZTcpData &data)
    {
        ds<<data.m_Ip;
        ds<<data.m_Port;
        ds<<data.m_Name;
        ds<<data.m_Time;
        ds<<data.m_Content;
        return ds;
    }
    friend QDebug operator<<(QDebug ds,const ZTcpData &data)
    {
        ds<<"sendArray:";
        ds<<data.m_Ip;
        ds<<data.m_Port;
        ds<<data.m_Name;
        ds<<data.m_Time;
        ds<<data.m_Content;
        return ds;
    }
    friend QDataStream &operator>>(QDataStream &ds,ZTcpData &data)
    {
        ds>>data.m_Ip;
        ds>>data.m_Port;
        ds>>data.m_Name;
        ds>>data.m_Time;
        ds>>data.m_Content;
        return ds;
    }
};

#endif // ZTCPDATA_H
